<template>
	<view class="forget">
		
		<view class="content">
			<!-- 主体 -->
			<view class="main">
				<view class="tips">若你忘记了密码，可在此重置新密码。</view>
				<uni-easyinput class="main-input" type="password" v-model="userInfo.phone" placeholder="请输入密码"></uni-easyinput>
				<uni-easyinput class="main-input" type="password" v-model="userInfo.password" placeholder="请输入密码"></uni-easyinput>
				<!-- <wInput
					v-model="verCode"
					type="number"
					maxlength="4"
					placeholder="验证码"
					
					isShowCode
					codeText="获取重置码"
					setTime="30"
					ref="runCode"
					@setCode="getVerCode()"
				></wInput> -->
			</view>
			<wButton 
				class="wbutton"
				text="重置密码"
				:rotate="isRotate" 
				@click.native="startRePass()"
			></wButton>

		</view>
	</view>
</template>

<script setup>
const isRotate = ref(false) //是否加载中
import wButton from '../../components/watch-button.vue' //button
import {forgetApi} from '@/apis/user.js'
const userInfo = ref({ password: '', phone: '' })
const startRePass = async() => {
	//重置密码
	if(isRotate.value){
		//判断是否加载中，避免重复点击请求
		return false;
	}
	if (userInfo.value.phone.length != 11) {
		uni.showToast({
			icon: 'none',
			position: 'bottom',
			title: '手机号不正确'
		});
		return false;
	}
	if (userInfo.value.password.length < 6) {
		uni.showToast({
			icon: 'none',
			position: 'bottom',
			title: '密码不正确'
		});
		return false;
	}
	const res = await forgetApi()
	if (res == 200) {
		console.log("重置密码成功")
	}
	isRotate.value=true
	setTimeout(function(){
		isRotate.value=false
	},2000)
}
</script>

<style>
	@import url("../../components/css/icon.css");
	@import url("./css/main.css");
</style>

